﻿@{
    Layout = null;
    string bbsName = this.ViewContext.RouteData.Values["BBSName"].ToString();
    string qr_guid = Guid.NewGuid().ToString();
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>AuthRedirection</title>
</head>
<body>
    <div>
        <img id="qr" />
        @*<input id="btnredirect" type="button" value="查询用户" onclick="SetTimeToVisit();" />*@
    </div>
    <script src="/static/global/gmu/dist/zepto.min.js"></script>
    <script src="/static/global/gmu/src/extend/selector.js"></script>
    <script src="/static/global/gmu/src/extend/compatibleIE9.js"></script>
    <script src="/static/BenzBBS/js/jquery.cookie.js"></script>
    <!-- 公用js begin -->
    <script type="text/javascript" charset="utf-8" src="/static/BenzBBS/js/script.js"></script>
    <!-- 公用js begin -->
    <script type="text/javascript">
        Zepto(function ($) {
            var ws = new WebSocket("ws://192.168.1.91:8888");
            ws.onopen = function () {
                console.log("onopen");
            }
            ws.onmessage = function (e) {
                var responseJSON = $.parseJSON(e.data);
                if (responseJSON.Result == "Success") {
                    //授权成功
                    $.cookie(responseJSON.Data.Cookie.Key, responseJSON.Data.Cookie.Value, { expires: 0.08 });
                    window.location.href = responseJSON.Data.Redirect;
                    return;
                }
                $("#qr").attr("src", "http://192.168.1.132:8080/bbs/benz/createqrcode?qr_guid=" + responseJSON.SessionID);
            }
            ws.onclose = function () {
                console.log("onclose");
            }
            ws.onerror = function () {
                console.log("onerror");
            }
        })
    </script>
    @*<script type="text/javascript">
        setInterval("SetTimeToVisit()", 3000);
        function SetTimeToVisit() {
            $.ajax({
                type: "GET",
                url: "/bbs/@bbsName/getqrcodetoken",
                dataType: "json",
                data: { qr_guid: "@qr_guid" },
                success: function (objInvokeResult) {
                    if (objInvokeResult.ResultCode == "Success") {
                        window.location.href = objInvokeResult.Data;
                    }
                }
            });
        }
    </script>*@
</body>
</html>
